package com.itheima.reggie.dao;

import com.itheima.reggie.entity.Setmeal;
import com.itheima.reggie.entity.SetmealDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetmealDao {
    @Select("SELECT COUNT(*) FROM setmeal WHERE category_id=#{categoryId}")
    Integer findCountByCategoryId(Long id);

    /**
     * 保存
     * @param setmealDto
     */
    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id" )
    void save(SetmealDto setmealDto);

    List<Setmeal> findSetmealById(@Param("name") String name);

    void delete(List<Long> ids);


    Integer findStatusByIds(@Param("ids") List<Long> ids);

    void batchDelete(@Param("ids") List<Long> ids);

    List<Setmeal> findAllBycategoryId(@Param("categoryId") Long categoryId, @Param("status")Integer status);

}
